package cn.bb.shop.api.Impl;

import cn.bb.shop.api.IShopOrder;


import java.io.IOException;
import java.net.Socket;

public class ShopOrderCustomer{
    public static void main(String[] args) throws IOException {
       String reponseData = "";
       try {
          Socket client = new Socket("127.0.0.1",8080);
          //服务器端的包   类  方法 的参数和类型
          String packageName = "cn.bb.shop.api.Impl/r/n";
          String className = "ShopOrder/r/n";
          String method = "getOrder/r/n";
          String argVal = "NO:008/r/n";
          //编码  往通道中写入这4个值
          client.getOutputStream().write(packageName.getBytes());
          client.getOutputStream().write(className.getBytes());
          client.getOutputStream().write(method.getBytes());
          client.getOutputStream().write(argVal.getBytes());

          client.shutdownOutput();
          //获取服务器返回的值
          byte[] b = new byte[1];
          while(client.getInputStream().read(b)!=-1) {
             reponseData = reponseData + new String(b);
          }

          System.out.println("服务器端返回的值："+reponseData);

       } catch (Exception e) {
          // TODO: handle exception
       }


    }
}
